#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
using namespace std;
vector<int> read_file(string& filename){
    ifstream if_handle(filename,ios::in);
    int c;
    vector<int> result;
    if(if_handle){
        while((c = if_handle.get())!=EOF)
            result.push_back(c);
    } else{
        cout<<"不能打开文件"<<endl;
    }
    return result;
}
void sort_vector(vector<int>& a){
    int n = a.size();
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            if(a.at(i)<=a.at(j))
                swap(a.at(i),a.at(j));
        }
    }
}
bool write_result(string filename,vector<int>& a){
    ofstream ofhandle(filename,ios::out);
    if(ofhandle){
        for(auto i:a){
            ofhandle.put(i).put(' ');
        }
        return true;
    }
    return false;
}
int main() {
    vector<int> a;
    int t;
    ofstream out_file("../test_out",ios::out);
    string in_file ="../test_in";
    a = read_file(in_file);
    sort_vector(a);
    if(write_result("../test_out",a))
        cout<<"成功写入结果"<<endl;
    return 0;
}